package kr.co.owls.data;

public class PointVO {
	String locationName;
	Double latitude;
	Double longitude;
	public PointVO(String[] arr) {
		this(arr[0], new Double(arr[1]), new Double(arr[2]));
	}
	public PointVO(String location, Double latitude, Double longitude) {
		this.locationName = location;
		this.latitude = latitude;
		this.longitude = longitude;
	}
	@Override
	public String toString() {
		return locationName + ":" + latitude + ":" + longitude + "\n";
	}
	public ResultVO calcDistance(PointVO vo){
		double thisLat = this.latitude;
		double thisLong = this.longitude;
		double otherLat = vo.latitude;
		double otherLong = vo.longitude;
		final int radius = 6371009;
		double getLat = Math.toRadians(thisLat - otherLat);
		double getLong = Math.toRadians(thisLong - otherLong);
		double a = (Math.sin(getLat / 2) * Math.sin(getLat / 2))
				+ (Math.cos(Math.toRadians(thisLong))
						* Math.cos(Math.toRadians(otherLong)) * (Math
						.sin(getLong / 2) * Math.sin(getLong / 2)));
		double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
		double distance = radius * c;
		return new ResultVO(this.locationName, distance);
	}
};
